{% extends 'accounts/asset_base.html' %}
{% load account_nav %}

{% block scripts %}
  {{ block.super }}
  <script type="text/javascript" src="/media/js/asset-edit.js" ></script>
{% endblock %}

{% block scripts-init %}
  {{ block.super }}
  TabtasticInit();
  preserveCurrentTab("edit-form", "form-tabs");
  ChangeHistory.init("/account/changes/{{ asset_type }}/{{ user_asset.asset.id }}/");
{% endblock %}

{% block h1 %}{{ user_asset.asset|capfirst|escape }}{% endblock %}

{% block account-forms %}
  <div id="tabs-and-sidebar">
  <form id="edit-form" action="{{ request.path }}" method="post">

    <ul class="tabset_tabs" id="form-tabs">
      {% block tabs %}
      <li><a href="#ownership"> Ownership
      </a></li>
      <li><a href="#change-history"> Change History
      </a></li>
      {% endblock %}
    </ul>

    {% block tab-content %}
    <div id="ownership" class="tabset_content unlabeled">
      <h2 class="tabset_label">Ownership</h2>

      <div class="form-row">
        {{ form.EditAssetForm.access_levels.NONE }}
        <div class="radio">
          <p class="note">
            Remove this {{ asset_type_name }} from your inventory.
            The {{ asset_type_name }} and its change history will continue
            to exist. You or another user may reclaim this {{ asset_type_name }} later.
          </p>
        </div>
      </div>

      <div class="form-row">
        {{ form.EditAssetForm.access_levels.COMMUNITY }}
        <div class="radio">
          <p class="note">
            Anyone can add this {{ asset_type_name }} to their inventory, and
            anyone can change its settings. This {{ asset_type_name }} keeps a
            permanent change history. Any changes can be audited and, if necessary,
            reverted.
          </p>
        </div>
      </div>

      <div class="form-row">
        {{ form.EditAssetForm.access_levels.EXCLUSIVE }}
        <div class="radio">
          <p class="note">
            You have total control over this {{ asset_type_name }}. Only one person
            may claim exclusive access for a single {{ asset_type_name }}. When you
            have exclusive access, other users may not edit this {{ asset_type_name }}
            or add it to their account.
          </p>
          {% if other_community_user_assets %}
            <p class="note">
	      <strong>Other people currently have community-level access to this {{ asset_type_name }}.</strong>
              If you select exclusive access for {{ user_asset.asset|capfirst }}, these people
	      will have their access revoked:
              <ul class="person-list">
                {% for userasset in other_community_user_assets|dictsort:"user" %}
                  <li>
                    <span class="change-detail">Access since {{ userasset.date_added|date:"Y-m-d @ H:i T" }}</span>
                    {% person userasset.user %}
                  </li>
                {% endfor %}
              </ul>
            </p>
          {% endif %}
          <p class="note">
            By selecting exclusive access for this {{ asset_type_name }}, you agree to
            allow us to e-mail you in the event of an ownership dispute.
          </p>
        </div>
      </div>
    </div>

    <div id="change-history" class="tabset_content unlabeled">
      <h2 class="tabset_label">Change History</h2>
      <ul id="changesets"></ul>
      <div id="changes-loading" class="ajax-loader"></div>
      <div id="more-changes"><a onclick="ChangeHistory.loadNextPage()"><span id="more-changes-count"></span> more changes...</a></div>
    </div>
    {% endblock %}

    {% block sidebar %}{% endblock %}

    <div class="unlabeled"> <div class="submit-row">
      <div>&raquo;</div> <input type="submit" value="Save" />

      {% ifequal user_asset.access ACCESS.COMMUNITY %}
        <p class="warning">
           This is a community-owned {{ asset_type_name }}.
           <em>Please be considerate when submitting changes.</em>
           Your IP address will be logged publicly,
           and vandalism will not be tolerated.
        </p>
      {% endifequal %}
    </div></div>

  </form>
  </div>
{% endblock %}

